package com.ghxxzx.daglcustom.controller.task;

import com.ghxxzx.daglcustom.utils.ActivitiTools;
import org.activiti.engine.HistoryService;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.history.HistoricTaskInstanceQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/task")
public class TaskController {

	@Autowired
	private HistoryService historyService;

	@RequestMapping("/get_list_by_instance")
	public List<Map<String, Object>> get_list_by_instance(String processInstanceId) {
		HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
				.processInstanceId(processInstanceId);
		List<HistoricTaskInstance> list2 = historicTaskInstanceQuery.list();

		return ActivitiTools.turnHistoricTaskInstance(list2);
	}
}